#!/usr/bin/perl
# header.pl
use warnings;
use strict;

my (@head, @body);

while (<>) {
   if (1 .. /^$/) {
      push @head, $_;
   } else {
      push @body, $_;
      last;   # found start of body, quit loop
   }
}

push @body, <>;
print "Head: \n", join('', @head);
print "Body: \n", join('', @body);